<template>
    <div class="paperPreview">
        <div v-if="paperId&&!isItem" style="text-align:center;margin-bottom:20px;">
            <table border="1" width="100%">
                <thead>
                    <tr>
                        <th>试题名称</th>
                        <th>题目数量</th>
                        <th>满分</th>
                        <th>及格分</th>
                        <th>时长（分钟）</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>{{paperInfo.title}}</td>
                        <td>{{paperInfo.judgeNum+paperInfo.singleNum+paperInfo.multiNum+paperInfo.operationNum}}</td>
                        <td>{{paperInfo.totalScore}}</td>
                        <td>{{paperInfo.passScore}}</td>
                        <td>{{paperInfo.examTime}}</td>
                    </tr>
                </tbody>
            </table>
        </div>
        <div class="content">
            <question
                v-if="type"
                :subjectList="questionList"
                :isAction='false'
                :isHaveCheck="false"
            >
            </question>
            <question
                v-else
                :subjectList="questionList"
                :isAction='false'
                :isHaveCheck="false"
                :isScore="true"
            >
            </question>
        </div>
    </div>
</template>
<script>
import question from "@/components/common/question"
import {paperPreviewApi,getQuestionListApi} from "@/request/api.js"
export default {
    name:'paperPreview',
    components: {question},
    created(){
        this.paperId=this.$route.query.id
        this.type=this.$route.query.type
        this.isItem=this.$route.query.isItem
        this.init()
    },
    data(){
        return{
            type:'',
            paperData:{},
            questionList:[],
            paperId:null,
            paperInfo:{},
            isItem:false
        }
    },
    methods:{
        init(){
            if(this.isItem){
                this.getToken(getQuestionListApi,{'questionLibId':this.paperId},res=>{
                    this.questionList=res.data.rows.map(item=>({...item,'isShowAnswer':true}))
                })
            }else{
                this.getToken(paperPreviewApi,{'paperId':this.paperId},res=>{
                    this.paperInfo=res.data
                    this.questionList=res.data.question.map(item=>({...item,'isShowAnswer':true}))
                })
            }
            
        },
    }
}
</script>
<style lang="stylus" scoped>
.paperPreview
    padding:30px
    height:100%;
    overflow-y:scroll;
</style>


